<template>
  <el-dialog
    top="30px"
    width="1000px"
    title="项目资料"
    append-to-body
    :close-on-click-modal="false"
    :visible.sync="visible"
    :before-close="beforeClose"
  >
    <div class="px-4">
      <h4 class="attach-title mt-1">
        <span>客户名称</span>
        <span style="margin-left: 120px" class="text-primary">{{ related.customer_name }}</span>
      </h4>
    </div>
    <hr />
    <div class="px-4">
      <h4 class="attach-title mt-1">
        <div class="d-flex justify-content-between align-items-center">
          <div>立项附件</div>
          <div>
            <el-button type="text" @click="showAttach = !showAttach">
              <i :class="`fa fa-sort-${showAttach ? 'asc' : 'desc'}`"></i>
            </el-button>
          </div>
        </div>
      </h4>
      <attach-item
        ref="item"
        v-bind="$attrs"
        v-on="$listeners"
        v-show="showAttach"
        @getRelated="getRelatedData"
        :related-id="queryId"
      ></attach-item>
      <hr />
      <attach-invest
        ref="invest"
        v-bind="$attrs"
        v-on="$listeners"
        :related-id="queryId"
      ></attach-invest>
    </div>
  </el-dialog>
</template>

<script>
import AttachItem from '@/credit/views/city/self/normal/item/AttachMain'

import AttachInvest from '@/credit/views/city/self/normal/invest/AttachMain'

export default {
  components: {
    AttachItem,
    AttachInvest,
  },
  props: {
    queryId: String,
    visible: Boolean,
  },
  data() {
    return {
      showAttach: true,
      related: {},
    }
  },
  computed: {},
  watch: {
    visible: {
      handler: function (val) {
        if (val) {
          this.$nextTick(() => {
            this.$refs.item.getData()
            this.$refs.invest.getData()
          })
        }
      },
      immediate: true,
    },
  },
  created() {},
  mounted() {},
  methods: {
    getRelatedData(data) {
      this.related = data || {}
    },
    beforeClose() {
      this.$emit('update:visible', false)
    },
  },
}
</script>

<style lang="scss" scoped>
.attach-title {
  font-size: 1.1rem;
  font-weight: bold;
}
</style>
